home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 44 / PC Actual CD 44.iso / Linux / Cygwin / full.exe / Disk1 / data1.cab / Tools / H-i586-cygwin32 / i586-cygwin32 / include / mingw32 / float.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-04  |  5.2 KB  |  197 lines

  1. /* 
  2.  * float.h
  3.  *
  4.  * Constants related to floating point arithmetic.
  5.  *
  6.  * Also included here are some non-ANSI bits for accessing the floating
  7.  * point controller.
  8.  *
  9.  * NOTE: GCC provides float.h, and it is probably more accurate than this,
  10.  *       but it doesn't include the non-standard stuff for accessing the
  11.  *       fp controller. (TODO: Move those bits elsewhere?) Thus it is
  12.  *       probably not a good idea to use the GCC supplied version instead
  13.  *       of this header.
  14.  *
  15.  * This file is part of the Mingw32 package.
  16.  *
  17.  * Contributors:
  18.  *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
  19.  *
  20.  *  THIS SOFTWARE IS NOT COPYRIGHTED
  21.  *
  22.  *  This source code is offered for use in the public domain. You may
  23.  *  use, modify or distribute it freely.
  24.  *
  25.  *  This code is distributed in the hope that it will be useful but
  26.  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  27.  *  DISCLAMED. This includes but is not limited to warranties of
  28.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  29.  *
  30.  * $Revision: 1.2 $
  31.  * $Author: noer $
  32.  * $Date: 1998/10/10 00:51:16 $
  33.  *
  34.  */
  35.  
  36. #ifndef _FLOAT_H_
  37. #define _FLOAT_H_
  38.  
  39. #define FLT_ROUNDS    1
  40. #define FLT_GUARD    1
  41. #define FLT_NORMALIZE    1
  42.  
  43. /*
  44.  * The characteristics of float.
  45.  */
  46.  
  47. /* The radix for floating point representation. */
  48. #define FLT_RADIX    2
  49.  
  50. /* Decimal digits of precision. */
  51. #define FLT_DIG        6
  52.  
  53. /* Smallest number such that 1+x != 1 */
  54. #define FLT_EPSILON    1.19209290e-07F
  55.  
  56. /* The number of base FLT_RADIX digits in the mantissa. */
  57. #define FLT_MANT_DIG    24
  58.  
  59. /* The maximum floating point number. */
  60. #define FLT_MAX        3.40282347e+38F
  61.  
  62. /* Maximum n such that FLT_RADIX^n - 1 is representable. */
  63. #define FLT_MAX_EXP    128
  64.  
  65. /* Maximum n such that 10^n is representable. */
  66. #define FLT_MAX_10_EXP    38
  67.  
  68. /* Minimum normalized floating-point number. */
  69. #define FLT_MIN        1.17549435e-38F
  70.  
  71. /* Minimum n such that FLT_RADIX^n is a normalized number. */
  72. #define FLT_MIN_EXP    (-125)
  73.  
  74. /* Minimum n such that 10^n is a normalized number. */
  75. #define FLT_MIN_10_EXP    (-37)
  76.  
  77.  
  78. /*
  79.  * The characteristics of double.
  80.  */
  81. #define DBL_DIG        15
  82. #define DBL_EPSILON    1.1102230246251568e-16
  83. #define DBL_MANT_DIG    53
  84. #define DBL_MAX        1.7976931348623157e+308
  85. #define DBL_MAX_EXP    1024
  86. #define DBL_MAX_10_EXP    308
  87. #define DBL_MIN        2.2250738585072014e-308
  88. #define DBL_MIN_EXP    (-1021)
  89. #define DBL_MIN_10_EXP    (-307)
  90.  
  91.  
  92. /*
  93.  * The characteristics of long double.
  94.  * NOTE: long double is the same as double.
  95.  */
  96. #define LDBL_DIG    15
  97. #define LDBL_EPSILON    1.1102230246251568e-16L
  98. #define LDBL_MANT_DIG    53
  99. #define LDBL_MAX    1.7976931348623157e+308L
  100. #define LDBL_MAX_EXP    1024
  101. #define LDBL_MAX_10_EXP    308
  102. #define LDBL_MIN    2.2250738585072014e-308L
  103. #define LDBL_MIN_EXP    (-1021)
  104. #define LDBL_MIN_10_EXP    (-307)
  105.  
  106.  
  107. /*
  108.  * Functions and definitions for controlling the FPU.
  109.  */
  110. #ifndef    __STRICT_ANSI__
  111.  
  112. /* TODO: These constants are only valid for x86 machines */
  113.  
  114. /* Control word masks for unMask */
  115. #define    _MCW_EM        0x0008001F    /* Error masks */
  116. #define    _MCW_IC        0x00040000    /* Infinity */
  117. #define    _MCW_RC        0x00000300    /* Rounding */
  118. #define    _MCW_PC        0x00030000    /* Precision */
  119.  
  120. /* Control word values for unNew (use with related unMask above) */
  121. #define    _EM_INVALID    0x00000010
  122. #define    _EM_DENORMAL    0x00080000
  123. #define    _EM_ZERODIVIDE    0x00000008
  124. #define    _EM_OVERFLOW    0x00000004
  125. #define    _EM_UNDERFLOW    0x00000002
  126. #define    _EM_INEXACT    0x00000001
  127. #define    _IC_AFFINE    0x00040000
  128. #define    _IC_PROJECTIVE    0x00000000
  129. #define    _RC_CHOP    0x00000300
  130. #define    _RC_UP        0x00000200
  131. #define    _RC_DOWN    0x00000100
  132. #define    _RC_NEAR    0x00000000
  133. #define    _PC_24        0x00020000
  134. #define    _PC_53        0x00010000
  135. #define    _PC_64        0x00000000
  136.  
  137. /* Return values for fpclass. */
  138. #define    _FPCLASS_SNAN    0x0001    /* Signaling "Not a Number" */
  139. #define    _FPCLASS_QNAN    0x0002    /* Quiet "Not a Number" */
  140. #define    _FPCLASS_NINF    0x0004    /* Negative Infinity */
  141. #define    _FPCLASS_NN    0x0008    /* Negative Normal */
  142. #define    _FPCLASS_ND    0x0010    /* Negative Denormal */
  143. #define    _FPCLASS_NZ    0x0020    /* Negative Zero */
  144. #define    _FPCLASS_PZ    0x0040    /* Positive Zero */
  145. #define    _FPCLASS_PD    0x0080    /* Positive Denormal */
  146. #define    _FPCLASS_PN    0x0100    /* Positive Normal */
  147. #define    _FPCLASS_PINF    0x0200    /* Positive Infinity */
  148.  
  149. #ifndef RC_INVOKED
  150.  
  151. #ifdef    __cplusplus
  152. extern "C" {
  153. #endif
  154.  
  155. /* Set the FPU control word as cw = (cw & ~unMask) | (unNew & unMask),
  156.  * i.e. change the bits in unMask to have the values they have in unNew,
  157.  * leaving other bits unchanged. */
  158. unsigned int    _controlfp (unsigned int unNew, unsigned int unMask);
  159. unsigned int    _control87 (unsigned int unNew, unsigned int unMask);
  160.  
  161.  
  162. unsigned int    _clearfp ();    /* Clear the FPU status word */
  163. unsigned int    _statusfp ();    /* Report the FPU status word */
  164. #define        _clear87    _clearfp
  165. #define        _status87    _statusfp
  166.  
  167. void        _fpreset ();    /* Reset the FPU */
  168.  
  169. /* Global 'variable' for the current floating point error code. */
  170. int *    __fpecode();
  171. #define    _fpecode    (*(__fpecode()))
  172.  
  173. /*
  174.  * IEEE recommended functions
  175.  */
  176.  
  177. double    _chgsign    (double x);
  178. double    _copysign    (double dTo, double dFrom);
  179. double    _logb        (double x);
  180. double    _nextafter    (double x, double y);
  181. double    _scalb        (double x, long n);
  182.  
  183. int    _finite        (double x);
  184. int    _fpclass    (double x);
  185. int    _isnan        (double x);
  186.  
  187. #ifdef    __cplusplus
  188. }
  189. #endif
  190.  
  191. #endif    /* Not RC_INVOKED */
  192.  
  193. #endif    /* Not __STRICT_ANSI__ */
  194.  
  195. #endif /* _FLOAT_H_ */
  196.  
  197.